package com.bwie.controller;

import com.bwie.pojo.TbBrand;
import com.bwie.service.TbBrandService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import net.bytebuddy.implementation.bind.annotation.Pipe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/6/20 15:31
 * @Version 1.0
 */
@RestController
@RequestMapping("/shop/index")
public class IndexController {
    @Autowired
    TbBrandService tbBrandService;

    /**
     * 获取品牌分页列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getBrandList")
    public R getBrandList(@RequestBody PageInfoVo pageInfoVo){
        return tbBrandService.getBrandList(pageInfoVo);
    }

    /**
     * 添加品牌
     * @param tbBrand
     * @return
     */
    @PostMapping("/addBrand")
    public R addBrand(@RequestBody TbBrand tbBrand){
        return tbBrandService.addBrand(tbBrand);
    }

    /**
     * 修改品牌状态
     * @param tbBrand
     * @return
     */
    @PostMapping("/changeBrandStatus")
    public R changeBrandStatus(@RequestBody TbBrand tbBrand){
        return tbBrandService.changeBrandStatus(tbBrand);
    }

    /**
     * 根据品牌ID删除品牌
     * @param brandId
     * @return
     */
    @PostMapping("/deleteByBrandId/{brandId}")
    public R deleteByBrandId(@PathVariable("brandId") Integer brandId){
        return tbBrandService.deleteByBrandId(brandId);
    }

    /**
     * 批量删除品牌
     * @param tbBrandList
     * @return
     */
    @PostMapping("/deleteBatchBrand")
    public R deleteBatchBrand(@RequestBody List<TbBrand> tbBrandList){
        return tbBrandService.deleteBatchBrand(tbBrandList);
    }
}
